<?php 
echo $form_scripts.$form_begin;
$container_tr=join("&nbsp;", $form->_button_container["TR"]);
$container_bl=join("&nbsp;", $form->_button_container["BL"]);
$container_br=join("&nbsp;", $form->_button_container["BR"]);

if ($form->_status=='delete' || $form->_action=='delete' || $form->_status=='unknow_record'):
	$meco = $form->output;
	$meco = str_replace('class="tablerow"','class="tablerow" style="font-size:20px; align:center;" ',$meco);
	echo $meco."</td><td align='center'>".img("images/borrar.jpg");
else:
$codigo=trim($form->codigo->output);
$usuario=$this->session->userdata['usuario'];
$super=$this->datasis->dameval("SELECT usu_super FROM usuarios WHERE usu_login='$usuario'");

$exdes=$form->exdes->output;
$existen=$form->existen->output;
?>
<?php if(isset($form->error_string))echo '<div class="alert">'.$form->error_string.'</div>'; ?>
<table border='0' width="100%">
	<tr>
		<td>
			<?php if($form->_status=='show'){ ?>
			<table>
				<tr>
				<?php if ($form->_status=='show') { ?>
				<td colspan='3' >
				<a href="#" onclick="window.open('<?php echo base_url();?>inventario/sinv/kardex/<?php echo $form->_dataobject->get('id'); ?>', '_blank', 'width=800, height=700, scrollbars=No, status=Yes, resizable=Yes, screenx='+((screen.availWidth/2)-400)+', screeny='+((screen.availHeight/2)-300)+'');">
				<img src='<?php echo base_url() ?>images/mail_find.gif'></a> Kardex de Inventario
				</td>
				<?php } ?>
				</tr>
			</table>
			
			<?php } else { ?>
			<?php } // show ?>
		</td>
		<td align='center' valign='middle'>
			<?php  if ($form->activo->value=='N') echo "<div style='font-size:14px;font-weight:bold;background: #B40404;color: #FFFFFF'>***DESACTIVADO***</div>"; ?>&nbsp;
		</td>
		<td align='right'><?php echo $container_tr; ?></td>
	</tr>
</table>

<fieldset style='border: 1px outset #9AC8DA;background: #FFFFFF;'>
<legend class="titulofieldset" >Identificaci&oacute;n del Producto </legend>
<table border='0' width="100%">
	<tr>
		<td colspan='2' valign='top' width="50%">
			<table border=0 width="80%">
				<tr>
					<td width="72" class="littletableheaderc"><? echo $form->codigo->label ?></td>
					<?php if( $form->_status == "modify" ) { ?>
					<td width="364" class="littletablerow">
					<input readonly value="<?=$form->codigo->output ?>" class='input' size='45' style='background: #F5F6CE;'  /></td>
					<?php } else { ?>
					<td width="219" class="littletablerow"><?=$form->codigo->output ?></td>
					<?php } ?>
				</tr>
				<tr>
					<td class='littletableheaderc'><?=$form->csiigo->label   ?></td>
					<td class="littletablerow"><?=$form->csiigo->output   ?></td>
				</tr>
				<tr>
				  <td class='littletableheaderc'>Descripci&oacute;n</td>
				  <td class="littletablerow"><?=$form->descrip->output   ?></td>
			  </tr>
				<tr>
				  <td class='littletableheaderc'>Adicional</td>
				  <td class="littletablerow"><?=$form->descrip2->output   ?></td>
			  </tr>
				<tr>
				  <td class='littletableheaderc'>Caldeco</td>
				  <td class="littletablerow"><?=$form->caldeco->output   ?></td>
			  </tr>
			</table>
		</td>
		<td colspan='2' valign='top'>
			<table border=0 width="80%">
				<tr>
					<td width="30%" class='littletableheaderc'><?=$form->marca->label ?></td>
					<td class="littletablerow"><?=$form->marca->output   ?></td>
				</tr>
				<tr>
					<td class='littletableheaderc'><?=$form->modelo->label ?></td>
					<td class="littletablerow"><?=$form->modelo->output   ?></td>
				</tr>
			<tr>
				  <td class='littletableheaderc'><?=$form->clave->label ?></td>
				  <td class="littletablerow"><?=$form->clave->output   ?></td>
			  </tr>
				<tr>
					<td class="littletableheaderc"><?=$form->tipo->label ?></td>
					<td class="littletablerow"><?=$form->tipo->output   ?></td>
				</tr>
				<tr>
					<td class='littletableheaderc'><?=$form->activo->label ?></td>
					<td class="littletablerow"><?=$form->activo->output   ?></td>
				</tr>
			</table>
		</td>
	</tr>
</table>
</fieldset>
<div id="maintabcontainer">
	<ul>
		<li><a href="#tab2">Precios</a></li>
		<li><a href="#tab4">Costos</a></li>
		<li><a href="#tab1">Par&aacute;metros</a></li>
		<li><a href="#tab3">Existencias</a></li>
		<li><a href="#tab5">Especificaciones</a></li>
		<li><a href="#tab7">Compras</a></li>
		<li><a href="#tab8">Ventas</a></li>
		<li><a href="#tab6">Movimientos de Usuarios</a></li>
	</ul>
	<?php //<div class="tab_container"> ?>
<? $mSQL=$this->db->query("SELECT * from logusu WHERE comenta like '%$codigo%' and modulo='SINV' ORDER BY fecha DESC limit 10");?>
<div id="tab6" style='background:#EFEFFF'>
 <table width='70%'>
	<tr>
		<td valign='top'>
			<fieldset style='border: 1px outset #B45F04;background: #FFFFFF;'>
			<legend class="titulofieldset" >Lista de las 10 Ultimas  Actividades Realizadas al Producto</legend>
			<table border='0' width="100%" >
				<tr bgcolor="#A5C1A5">
					<td class='littletableheaderc' width="15%" align="center">Fecha</td>
					<td class="littletableheaderc" width="15%" align="center">Hora</td>
				    <td class="littletableheaderc" width="15%" align="center">Usuario</td>
				    <td class="littletableheaderc" width="55%" align="left">Actividad</td>
				</tr>
				<? foreach($mSQL->result() as $items){?>
				<tr>
					<td class='littletablerow' align="center"><?= dbdate_to_human($items->fecha) ?></td>
					<td class="littletablerow" align="center"><?= $items->hora   ?></td>
				    <td class="littletablerow" align="center"><?= $items->usuario?></td>
				    <td class="littletablerow" align="left"><?= $items->comenta?></td>
				</tr>
				<? } ?>
			</table>
			 </legend>
	        </fieldset>
		</td>
		</tr>
	</table>
</div>
	<div id="tab5" style='background:#EFEFFF'>
		<table>
			<tr>
				<td class='littletableheaderc'><?=$form->foto->label ?></td>
				<td colspan="3" nowrap class="littletablerow"><?=$form->foto->output   ?></td>
			</tr>
		</table>
		<fieldset style='border: 1px outset #B45F04;background: #FFEFFF;'>
		<legend class="titulofieldset" >Especificaci&oacute;nes T&eacute;cnicas</legend>
		<table border='0' width="100%" >
				<tr>
					<td class='littletableheaderc' width="20%"><?= $form->espe1->label ?></td>
					<td class="littletablerow"><?= $form->espe1->output   ?></td>
				    <td class="littletableheaderc"><?= $form->espe3->label ?></td>
				    <td class="littletablerow"><?= $form->espe3->output   ?></td>
				</tr>
				<tr>
					<td class='littletableheaderc'><?= $form->espe2->label ?></td>
					<td class="littletablerow"><?= $form->espe2->output   ?></td>
				    <td class="littletableheaderc"><?= $form->espe4->label ?></td>
				    <td  class="littletablerow"><?= $form->espe4->output   ?></td>
				</tr>
			</table>
			 </legend>
	        </fieldset>
    </div>
    <div id="tab4" style='background:#EFEFFF'>
		<fieldset style='border: 1px outset #B45F04;background: #FFEFFF;'>
		<legend class="titulofieldset" >Resumen de Costo Promedio por Mes</legend>
		<table border='0' width="90%" >
				<tr align='center'>
					<td class='littletableheaderc' >Fecha</td>
					<td class='littletableheaderc' >Costo Promedio ME</td>
					<td class='littletableheaderc' >Costo Promedio MN</td>
                    <td class='littletableheaderc' >Existencia</td>
                    <td class='littletableheaderc' >Costo Ultimo ME</td>
                    <td class='littletableheaderc' >Costo Ultimo MN</td>
                    <td class='littletableheaderc' >Compra</td>
                    <td class='littletableheaderc' >Costo Compra ME</td>
                    <td class='littletableheaderc' >Costo Compra MN</td>
                    <td class='littletableheaderc' >Fecha factura</td>
				</tr>
			<? foreach($costos as $items ){?>
				<tr>
					<td class="littletablerow" align='center'><?= dbdate_to_human($items->fecha) ?></td>
					<td class="littletablerow" align='right'><?= nformat($items->costome,5)   ?></td>
					<td class="littletablerow" align='right'><?= nformat($items->costomn,5)   ?></td>
                    <td class="littletablerow" align='right'><?= $items->existen   ?></td>
                    <td class="littletablerow" align='right'><?= nformat($items->ultimo,5)   ?></td>
                    <td class="littletablerow" align='right'><?= nformat($items->ultimomn,5)   ?></td>
                    <td class="littletablerow" align='right'><?= $items->compra   ?></td>
                    <td class="littletablerow" align='right'><?= nformat($items->pcompra,5)   ?></td>
                    <td class="littletablerow" align='right'><?= nformat($items->compramn,5)   ?></td>
                    <td class="littletablerow" align='center'><?= dbdate_to_human($items->ffecha) ?></td>
				</tr>
			<?}?>
			</table>
			 </legend>
	        </fieldset>
    </div>
	<div id="tab1" style='background:#EFEFFF'>
	<table width="100%" border='0'>
	<tr>
		<td colspan='2' valign='top'  style='border-collapse;border: 1px dotted'>
			<table border='0' >
				<tr>
					<td width='100' class='littletableheaderc'><?=$form->depto->label ?></td>
					<td nowrap class="littletablerow"><?=$form->depto->output   ?></td>
				</tr>
				<tr style="height:14px">
					<td class='littletableheaderc'><?=$form->linea->label ?></td>
					<td class="littletablerow" id='td_linea'><?=$form->linea->output?></td>
				</tr>
				<tr>
					<td class='littletableheaderc'><?=$form->grupo->label ?></td>
					<td nowrap class="littletablerow" id='td_grupo'><?=$form->grupo->output   ?></td>
				</tr>
			</table>		</td>
	  </tr>
	</table>
	<table width="100%" border='0'>
	<tr>
		<td width="25%"  align='left' valign='top'>
		<table border='0' width='100%'>
				<tr>
					<td width='91' class='littletableheaderc'><?=$form->alto->label ?></td>
					<td width="192" class="littletablerow"><?=$form->alto->output   ?></td>
				</tr>
				<tr>
					<td class='littletableheaderc'><?=$form->ancho->label ?></td>
					<td class="littletablerow"><?=$form->ancho->output   ?></td>
				</tr>
				<tr>
					<td class='littletableheaderc'><?=$form->largo->label ?></td>
					<td class="littletablerow"><?=$form->largo->output   ?></td>
				</tr>
		  </table></td>
	    <td width="25%"  align='left' valign='top'>
		<table border='0'  width='100%'>
				<tr>
					<td width="55%" class='littletableheaderc'><?=$form->peso->label ?></td>
					<td width="45%" class="littletablerow"><?=$form->peso->output   ?></td>
				</tr>
				<tr>
					<td class='littletableheaderc'><?=$form->unidad->label ?></td>
					<td class="littletablerow"><?=$form->unidad->output   ?></td>
				</tr>
				<tr>
					<td class='littletableheaderc'><?=$form->span->label ?></td>
					<td class="littletablerow"><?=$form->span->output   ?></td>
				</tr>
				<tr>
					<td class='littletableheaderc'><?=$form->nhilos->label ?></td>
					<td class="littletablerow"><?=$form->nhilos->output   ?></td>
				</tr>
		  </table>
	    </td>
	    <td  align='left' valign='top'></td>
      </tr>
	</table>
</div>
<div id="tab2" style='background:#EFEFFF'>
	<table width='20%'>
		<tr>
			<td class="littletableheaderc"><?=$form->moneda->label    ?></td>
			<td class="littletablerow" ><?=$form->moneda->output  ?></td>
		</tr>
	<table/>
	<table width='100%'>
	<tr>
		<td valign='top'>
			<fieldset style='border: 1px outset #B45F04;background: #FFEFFF;'>
			<legend class="titulofieldset" >Costos</legend>
			<table width='100%'>
				<tr>
					<td class="littletableheaderc"><?=$form->costofob->label    ?></td>
					<td class="littletablerow" ><?=$form->costofob->output  ?></td>
				</tr>
				<tr>
					<td class="littletableheaderc"><?=$form->costocif->label    ?></td>
					<td class="littletablerow" ><?=$form->costocif->output  ?></td>
				</tr>
				<tr>
					<td class="littletableheaderc"><?=$form->porcgasto->label    ?></td>
					<td class="littletablerow"><?=$form->porcgasto->output  ?></td>
				</tr>
				<tr>
					<td class="littletableheaderc"><?=$form->ultimo->label   ?></td>
					<td class="littletablerow" align='left'><?=$form->ultimo->output  ?></td>
				</tr>
				<tr>
					<td class="littletableheaderc"><?=$form->pond->label   ?></td>
					<td class="littletablerow" align='left'><?=$form->pond->output  ?></td>
				</tr>
				<tr>
					<td class="littletableheaderc"><?=$form->iva->label   ?></td>
					<td class="littletablerow" ><?=$form->iva->output ?></td>
				</tr>
				<tr>
					<td class="littletableheaderc"><?=$form->formcal->label   ?></td>
					<td class="littletablerow" ><?=$form->formcal->output ?></td>
				</tr>
				<tr>
				  <td class="littletableheaderc"><?=$form->redecen->label ?></td>
				  <td class="littletablerow"><?=$form->redecen->output?></td>
			  </tr>
			</table>	
			</fieldset>
		</td>
		<td valign='top'>
			<fieldset style='border: 1px outset #B45F04;background: #FFEFFF;'>
			<legend class="titulofieldset" style='font-size:16' >Precios de Venta </legend>
			<? $tiva=$this->datasis->traevalor('TIVA');?>
			<table width='100%' cellspacing='0' border="0">
				<tr>
					<td class="littletableheader" style='background: #3B240B;color: #FFEEFF;font-weight: bold' align='center'>Precio</td>
					<td class="littletableheader" style='background: #3B240B;color: #FFEEFF;font-weight: bold' align='center'>Margen</td>
					<td class="littletableheader" style='background: #3B240B;color: #FFEEFF;font-weight: bold' align='center'>Utilidad</td>
					<td class="littletableheader" style='background: #3B240B;color: #FFEEFF;font-weight: bold' align='center'>Base  </td>
					<td class="littletableheader" style='background: #3B240B;color: #FFEEFF;font-weight: bold' align='center'>Precio + <? echo $tiva ?></td>
				</tr>
			  	<tr>
					<td class="littletableheaderc" align='center'>1</td>
					<td class="littletablerow" align='center'><?=$form->margen1->output ?></td>
					<td class="littletablerow" align='center'><?=$form->utilidad1->output ?></td>
					<td class="littletablerow" align='center' ><?=$form->base1->output    ?></td>
					<td class="littletablerow" align='center'><?=$form->precio1->output ?></td>
				</tr>
				<tr>
					<td class="littletableheaderc" align='center'>2</td>
					<td class="littletablerow" align='center'><?=$form->margen2->output ?></td>
					<td class="littletablerow" align='center'><?=$form->utilidad2->output ?></td>
					<td class="littletablerow" align='center'><?=$form->base2->output   ?></td>
					<td class="littletablerow" align='center'><?=$form->precio2->output ?></td>
				</tr>
<? //IF($super=='S'){?>
				<tr>
					<td class="littletableheaderc" align='center'>3</td>
					<td class="littletablerow" align='center'><?=$form->margen3->output ?></td>
					<td class="littletablerow" align='center'><?=$form->utilidad3->output ?></td>
					<td class="littletablerow" align='center'><?=$form->base3->output   ?></td>
					<td class="littletablerow" align='center'><?=$form->precio3->output ?></td>
				</tr>
				<tr>
					<td class="littletableheaderc" align='center'>4</td>
					<td class="littletablerow" align='center'><?=$form->margen4->output ?></td>
					<td class="littletablerow" align='center'><?=$form->utilidad4->output ?></td>
					<td class="littletablerow" align='center'><?=$form->base4->output   ?></td>
					<td class="littletablerow" align='center'><?=$form->precio4->output ?></td>
				</tr>
<?// } ?>
				<tr>
					<td class="littletablerow">&nbsp;</td>
					<td class="littletablerow">&nbsp;</td>
					<td class="littletablerow">&nbsp;</td>
					<td class="littletablerow">&nbsp;</td>
				</tr>
			</table>	
			</fieldset>
		</td>
	</tr>
	</table>
</div>
<div id="tab3" style='background:#EFEFFF'>
	<table width='100%'>
	<tr>
  		<td valign="top" width="60%">
			<fieldset  style='border: 2px outset #FEB404;background: #FFFCE8;'>
			<legend class="titulofieldset" >Existencias</legend>
			<table width='100%' border=0 >
				<tr>
					<td class="littletableheaderc" width='120'><?=$form->existen->label  ?></td>
					<td class="littletablerow" align='left' ><?=$form->existen->output  ?></td>
				</tr>
				<tr>
					<td class="littletableheaderc" width='120'><?=$form->existen_max->label  ?></td>
					<td class="littletablerow" align='left' ><?=$form->existen_max->output  ?></td>
				</tr>
				<tr>
					<td class="littletableheaderc" width='120'><?=$form->existen_min->label  ?></td>
					<td class="littletablerow" align='left' ><?=$form->existen_min->output  ?></td>
				</tr>
			</table>
			</fieldset>	
		</td>
		<?php if( !empty($form->almacenes->output)) { ?>
		<td valign="top">
			<fieldset style='border: 1px outset #FEB404;background: #FFFCE8;'>
			<legend class="titulofieldset" >Almacenes</legend>
			<?php echo $form->almacenes->output ?>
			</fieldset>
		</td>
		<?php } ?>
	</tr>
	</table>
</div>
<div id="tab7" style='background:#EFEFFF'>
	<table width='80%'>
	<tr>
  		<td valign="top" width="60%">
			<fieldset style='border: 1px outset #FEB404;background: #BECDD8;'>
			<legend class="titulofieldset" >Ultimas 10 Compras</legend>
			<?php echo $form->compras->output ?>
			</fieldset>
		</td>
	</tr>
	</table>
</div>
<div id="tab8" style='background:#EFEFFF'>
	<table width='80%'>
	<tr>
  		<td valign="top" width="60%">
			<fieldset style='border: 1px outset #4D4D50;background: #FFFFFF;'>
			<legend class="titulofieldset" >Ultimas 10 Ventas</legend>
			<?php echo $form->ventas->output ?>
			</fieldset>
		</td>
	</tr>
	</table>
</div>
<?php echo $container_bl.$container_br; ?>
<?php echo $form_end?>
<?php endif; ?>
